﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Transactions;
using System.Runtime.Serialization;

using Unis.Framework.ORM.Attributes;
using Unis.Framework.RuleBase.Common;
using KingRoad.EPM.CompletionMaterialsEntity.Model;
using KingRoad.EPM.CompletionMaterialsDAL;
using System.Data;


namespace KingRoad.EPM.CompletionMaterialsDAL.BcdVolumeDirectoryService
{    
    /// <summary> 
    /// 文件生成时间 2017/5/17 16:05:12
    /// </summary> 
    public class BcdVolumedirectoryService :BaseService<BcdVolumedirectoryInfo>, IBcdVolumedirectoryService
    {
        public int DeleteByFlID(string Fl_ID)
        {
            string _modelMapXmlName = "BcdVolumedirectory";
            int ret = DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQuery(_modelMapXmlName, "DeleteByFlID", Fl_ID);
            return ret;
        }

        public int DeleteByPidFdid(string P_ID, string Fd_ID)
        {
            string _modelMapXmlName = "BcdVolumedirectory";
            int ret = DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQuery(_modelMapXmlName, "DeleteByPidFdid", P_ID, Fd_ID);
            return ret;
        }

        public int SplitVolume(string Vd_ID)
        {
            string _modelMapXmlName = "BcdVolumedirectory";
            int ret = DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQuery(_modelMapXmlName, "SplitVolume", Vd_ID);
            return ret;
        }

        public int CheckObject(BcdVolumedirectoryInfo info)
        {
            string _modelMapXmlName = "BcdVolumedirectory";
            int ret = DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQuery(_modelMapXmlName, "CheckObject", info.Vd_ID, info.Vd_State, info.Vd_CMan, info.Vd_CTime);
            return ret;
        }

        /// <summary>
        /// 根据项目id，文档类型id 获取该项目此文档类型下未归档文件个数
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public int GetCountBySql(string sql)
        {
            string strSql = "select Count(Vd_ID) as numb from View_VolumeList where " + sql;
            DataTable dt = DatabaseExcuteBySql.QuerybySql(strSql);
            return Convert.ToInt32(dt.Rows[0][0]);
        }
    }

}

